home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / idl / nsIArray.idl < prev    next >
Text File  |  2006-05-08  |  9KB  |  233 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is XPCOM Array interface.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corp.
  19.  * Portions created by the Initial Developer are Copyright (C) 2002
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *   Alec Flett <alecf@netscape.com>
  24.  *
  25.  * Alternatively, the contents of this file may be used under the terms of
  26.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  27.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.  * in which case the provisions of the GPL or the LGPL are applicable instead
  29.  * of those above. If you wish to allow use of your version of this file only
  30.  * under the terms of either the GPL or the LGPL, and not to allow others to
  31.  * use your version of this file under the terms of the MPL, indicate your
  32.  * decision by deleting the provisions above and replace them with the notice
  33.  * and other provisions required by the GPL or the LGPL. If you do not delete
  34.  * the provisions above, a recipient may use your version of this file under
  35.  * the terms of any one of the MPL, the GPL or the LGPL.
  36.  *
  37.  * ***** END LICENSE BLOCK ***** */
  38.  
  39. #include "nsISupports.idl"
  40.  
  41. interface nsISimpleEnumerator;
  42.  
  43. /**
  44.  * nsIArray
  45.  *
  46.  * An indexed collection of elements. Provides basic functionality for
  47.  * retrieving elements at a specific position, searching for
  48.  * elements. Indexes are zero-based, such that the last element in the
  49.  * array is stored at the index length-1.
  50.  *
  51.  * For an array which can be modified, see nsIMutableArray below.
  52.  *
  53.  * Neither interface makes any attempt to protect the individual
  54.  * elements from modification. The convention is that the elements of
  55.  * the array should not be modified. Documentation within a specific
  56.  * interface should describe variations from this convention.
  57.  *
  58.  * It is also convention that if an interface provides access to an
  59.  * nsIArray, that the array should not be QueryInterfaced to an
  60.  * nsIMutableArray for modification. If the interface in question had
  61.  * intended the array to be modified, it would have returned an
  62.  * nsIMutableArray!
  63.  *
  64.  * null is a valid entry in the array, and as such any nsISupports
  65.  * parameters may be null, except where noted.
  66.  *
  67.  * @status UNDER_REVIEW
  68.  */
  69. [scriptable, uuid(114744d9-c369-456e-b55a-52fe52880d2d)]
  70. interface nsIArray : nsISupports
  71. {
  72.     /**
  73.      * length
  74.      *
  75.      * number of elements in the array.
  76.      */
  77.     readonly attribute unsigned long length;
  78.  
  79.     /**
  80.      * queryElementAt()
  81.      *
  82.      * Retrieve a specific element of the array, and QueryInterface it
  83.      * to the specified interface. null is a valid result for
  84.      * this method, but exceptions are thrown in other circumstances
  85.      * 
  86.      * @param index position of element
  87.      * @param uuid the IID of the requested interface
  88.      * @param result the object, QI'd to the requested interface
  89.      *
  90.      * @throws NS_ERROR_NO_INTERFACE when an entry exists at the
  91.      *         specified index, but the requested interface is not
  92.      *         available.
  93.      * @throws NS_ERROR_ILLEGAL_VALUE when index > length-1
  94.      *
  95.      */
  96.     void queryElementAt(in unsigned long index,
  97.                         in nsIIDRef uuid,
  98.                         [iid_is(uuid), retval] out nsQIResult result);
  99.     
  100.     /**
  101.      * indexOf()
  102.      * 
  103.      * Get the position of a specific element. Note that since null is
  104.      * a valid input, exceptions are used to indicate that an element
  105.      * is not found.
  106.      * 
  107.      * @param startIndex The initial element to search in the array
  108.      *                   To start at the beginning, use 0 as the
  109.      *                   startIndex
  110.      * @param element    The element you are looking for
  111.      * @returns a number >= startIndex which is the position of the
  112.      *          element in the array.
  113.      * @throws NS_ERROR_NOT_FOUND if the element was not in the array.
  114.      */
  115.     unsigned long indexOf(in unsigned long startIndex,
  116.                           in nsISupports element);
  117.  
  118.     /**
  119.      * enumerate the array
  120.      *
  121.      * @returns a new enumerator positioned at the start of the array
  122.      * @throws NS_ERROR_FAILURE if the array is empty (to make it easy
  123.      *         to detect errors)
  124.      */
  125.     nsISimpleEnumerator enumerate();
  126.  
  127. };
  128.  
  129. /**
  130.  * nsIMutableArray
  131.  * A separate set of methods that will act on the array. Consumers of
  132.  * nsIArray should not QueryInterface to nsIMutableArray unless they
  133.  * own the array.
  134.  *
  135.  * As above, it is legal to add null elements to the array. Note also
  136.  * that null elements can be created as a side effect of
  137.  * insertElementAt(). Conversely, if insertElementAt() is never used,
  138.  * and null elements are never explicitly added to the array, then it
  139.  * is guaranteed that queryElementAt() will never return a null value.
  140.  *
  141.  * Any of these methods may throw NS_ERROR_OUT_OF_MEMORY when the
  142.  * array must grow to complete the call, but the allocation fails.
  143.  *
  144.  * @status UNDER_REVIEW
  145.  */
  146.  
  147. [scriptable, uuid(af059da0-c85b-40ec-af07-ae4bfdc192cc)]
  148. interface nsIMutableArray : nsIArray
  149. {
  150.     /**
  151.      * appendElement()
  152.      * 
  153.      * Append an element at the end of the array.
  154.      *
  155.      * @param element The element to append.
  156.      * @param weak    Whether or not to store the element using a weak
  157.      *                reference.
  158.      * @throws NS_ERROR_FAILURE when a weak reference is requested,
  159.      *                          but the element does not support
  160.      *                          nsIWeakReference.
  161.      */
  162.     void appendElement(in nsISupports element, in boolean weak);
  163.  
  164.     /**
  165.      * removeElementAt()
  166.      * 
  167.      * Remove an element at a specific position, moving all elements
  168.      * stored at a higher position down one.
  169.      * To remove a specific element, use indexOf() to find the index
  170.      * first, then call removeElementAt().
  171.      *
  172.      * @param index the position of the item
  173.      *
  174.      */
  175.     void removeElementAt(in unsigned long index);
  176.  
  177.     /**
  178.      * insertElementAt()
  179.      *
  180.      * Insert an element at the given position, moving the element 
  181.      * currently located in that position, and all elements in higher
  182.      * position, up by one.
  183.      *
  184.      * @param element The element to insert
  185.      * @param index   The position in the array:
  186.      *                If the position is lower than the current length
  187.      *                of the array, the elements at that position and
  188.      *                onwards are bumped one position up.
  189.      *                If the position is equal to the current length
  190.      *                of the array, the new element is appended.
  191.      *                An index lower than 0 or higher than the current
  192.      *                length of the array is invalid and will be ignored.
  193.      *
  194.      * @throws NS_ERROR_FAILURE when a weak reference is requested,
  195.      *                          but the element does not support
  196.      *                          nsIWeakReference.
  197.      */
  198.     void insertElementAt(in nsISupports element, in unsigned long index, in boolean weak);
  199.  
  200.     /**
  201.      * replaceElementAt()
  202.      *
  203.      * Replace the element at the given position.
  204.      *
  205.      * @param element The new element to insert
  206.      * @param index   The position in the array
  207.      *                If the position is lower than the current length
  208.      *                of the array, an existing element will be replaced.
  209.      *                If the position is equal to the current length
  210.      *                of the array, the new element is appended.
  211.      *                If the position is higher than the current length
  212.      *                of the array, empty elements are appended followed
  213.      *                by the new element at the specified position.
  214.      *                An index lower than 0 is invalid and will be ignored.
  215.      *
  216.      * @param weak    Whether or not to store the new element using a weak
  217.      *                reference.
  218.      *
  219.      * @throws NS_ERROR_FAILURE when a weak reference is requested,
  220.      *                          but the element does not support
  221.      *                          nsIWeakReference.
  222.      */
  223.     void replaceElementAt(in nsISupports element, in unsigned long index, in boolean weak);
  224.     
  225.     
  226.     /**
  227.      * clear()
  228.      *
  229.      * clear the entire array, releasing all stored objects
  230.      */
  231.     void clear();
  232. };
  233.